package com.chenwut.threadDemo.waitandnotify02;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author ChenPi
 * @since 2024/09/19 10:50
 */
public class Foodie extends Thread {

    ArrayBlockingQueue<String> queue;

    public Foodie(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true) {
            try {
                String food = queue.take();
                System.out.println(getName() + "拿到了一个" + food);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
